<%--
  Created by IntelliJ IDEA.
  User: xiaoji
  Date: 2014/11/3
  Time: 15:02
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java"  pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="z" uri="/WEB-INF/lib/zerdoor.tld"%>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<html>
<head>
    <title><spring:message code="task_detail.head"/></title>
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
    <link href="${path}/plugins/page/kkpager.css" rel="stylesheet">
    <script src="${path}/plugins/page/kkpager.js" type="text/javascript"></script>
    <script src="${path}/js/jquery.cookie.js" type="text/javascript"></script>
    <script type="text/javascript">
        var pageSize = 10;
        function initBeanInfo(page, rows) {
            //异步获取生产计划
            pageSize = rows;
            $.post("${path}/taskdetail/getBidInfo.html", {
                page: page,
                rows: rows,
                taskId: '${detail.itemId}'
            }, function (data) {
                var list = data.pageInfo.list;
                var htmlstr = "<ul>";
                var isBidButton = '${isBidButton}'
                if (list != null) {
                    for (var i = 0; i < list.length; i++) {
                        var obj = list[i];
                        var isBrowse = obj.isBrowse!=101001?"<spring:message code="task_detial.bid.isBrowse"/>":"<spring:message code="task_detial.bid.isBrowse2"/>";
                        var isRecom = obj.isRecom==101001?'<img src="${path}/style/acg/images/eliteico.png" />':'';
                        htmlstr +='<li class="first clearfix">'+
                        '<div class="eliteico">'+isRecom+'</div>'+
                        '<div class="artleft">'+
                        '       <img src="${path}/'+obj.headPortrait+'" width="120" height="120" class="artimg" />'+
                        '        <p><a href="${path}/usercenter/toUserMessagesHome.html?sender='+obj.userId+'" class="deltail_lxwm"><em class="icon"><spring:message code="task_detial.delegate.info.button"/></em></a></p>';
                        if(isBidButton == 1){
                            htmlstr += '        <p ><a href="javascript:void(0);" style="margin-top: 5px" onclick="addWinItemId('+obj.id+')" class="deltail_lxwm"><em class="icon" id="icon'+obj.id+'"><spring:message code='task_detial.message.msg1' /></em></a></p>';
                        }

                        if(obj.isbid == 101001){
                            htmlstr += '        <p ><a href="javascript:void(0);" style="margin-top: 5px"  class="deltail_lxwm"><em class="icon"><spring:message code='task_detial.message.msg2' /></em></a></p>';
                        }
                        if(obj.nickname == undefined){
                            obj.nickname=obj.userName;
                        }
                        htmlstr +='</div>'+
                        '<div class="artright">'+
                        '       <div class="artname clearfix">'+
                        '       <h3>'+obj.nickname+'</h3>'+
                        '<div class="shuxing">'+
                        '        <span>'+userAuth(obj.userAuth)+'</span>'+
                        '</div>'+
                        '</div>'+
                        '<div class="art_tit"><spring:message code="task_detial.bid.price"/>：<span class="price color_red">￥'+obj.budget+'</span></div>'+
                         '<div class="artcon"><div>'+obj.description+'</div>';
                        //只有委托方自己可以看见附件
                        var ismy = '${isMy}';
                        if(ismy == 1){
                            var attastr ="附件:";
                            if(obj.attachment != undefined){
                                var arrAtta = obj.attachment.split(",");
                                for(var j=0;j<arrAtta.length;j++){
                                    var imgname = arrAtta[j].substring(arrAtta[j].lastIndexOf("/")+1)+"&nbsp;&nbsp;";
                                    attastr+="<a href='javascript:void(0);' onclick='f_download(\""+arrAtta[j]+"\")'>"+imgname+"下载</a><br/>";
                                }
                            }
                            htmlstr += '<div>'+attastr+'</div>';
                        }

                        htmlstr +='</div>'+
                        '<div class="art_time"><em class="color_red">'+obj.createTime+'</em> &nbsp;&nbsp;&nbsp;&nbsp;'+
                        ' <em class="color_red">'+isBrowse+'</em></div>'+
                        '</div>'+
                        '<div class="clr"></div>'+
                        '</li>';
                    }
                    htmlstr+='</ul>';
                    $("#artistslist").html(htmlstr);
                    var pager = data.pageInfo;
                    //分页
                    createPage(pager.pageNum, pager.pages, pager.total);
                }

            },"json");
        }

        //分页方法
        //currentPage 当前页
        //rows 每页条数
        //total 总数
        function createPage(currentPage, totalPage, totalCount) {
            var totalPage = totalPage;
            var totalRecords = totalCount;
            var pageNo = currentPage;
            if (!pageNo) {
                pageNo = 1;
            }
            //生成分页
            //有些参数是可选的，比如lang，若不传有默认值
            kkpager.generPageHtml({
                pno: pageNo,
                //总页码
                total: totalPage,
                //总数据条数
                totalRecords: totalRecords,
                //链接前部
                hrefFormer: 'index',
                //链接尾部
                hrefLatter: '',
                //是否显示总页数
                isShowTotalPage: true,
                //是否显示总记录数
                isShowTotalRecords: true,
                //是否显示页码跳转输入框
                isGoPage: true,
                //getLink: function (n) {
                //    return this.hrefFormer + this.hrefLatter + "?pno=" + n;
                //}
                //,
                mode : 'click',//默认值是link，可选link或者click
                click : function(n){
                    //this.selectpage(n);
                    initBeanInfo(n, pageSize);
                    return false;
                },
                lang				: {
                    firstPageText			: '<spring:message code="firstPageText"/>',
                    firstPageTipText		: '<spring:message code="firstPageTipText"/>',
                    lastPageText			: '<spring:message code="lastPageText"/>',
                    lastPageTipText			: '<spring:message code="lastPageTipText"/>',
                    prePageText				: '<spring:message code="prePageText"/>',
                    prePageTipText			: '<spring:message code="prePageTipText"/>',
                    nextPageText			: '<spring:message code="nextPageText"/>',
                    nextPageTipText			: '<spring:message code="nextPageTipText"/>',
                    totalPageBeforeText		: '<spring:message code="totalPageBeforeText"/>',
                    totalPageAfterText		: '<spring:message code="totalPageAfterText"/>',
                    totalRecordsAfterText	: '<spring:message code="totalRecordsAfterText"/>',
                    gopageBeforeText		: '<spring:message code="gopageBeforeText"/>',
                    gopageButtonOkText		: '<spring:message code="gopageButtonOkText"/>',
                    gopageAfterText			: '<spring:message code="gopageAfterText"/>',
                    buttonTipBeforeText		: '<spring:message code="buttonTipBeforeText"/>',
                    buttonTipAfterText		: '<spring:message code="buttonTipAfterText"/>'
                }
            },true);
        }
        function userAuth(userAuth){
            if(userAuth == 101001){
                return "<spring:message code="task_detail.nickname_auth"/>";
            }else{
                return "<spring:message code="task_detail.nickname_auth2"/>";
            }
        }
        //中标
        function winItem(){
            $.post("${path}/taskdetail/winTotalNumItem.html",{
                ids:$("#ids").val(),
                itemId:'${detail.itemId}'
            },function(data){
                if(data.errormsg == undefined){
                    alert("<spring:message code='task_detial.message.msg3' />");
                    window.location.reload();
                }else{
                    alert("<spring:message code='task_detial.message.msg4' />");
                }
            },"json");
        }

        function addWinItemId(id){
            var ids = $("#ids").val();
            if(ids == ''){
                $("#ids").val(id);
            }else{
                var boo = true;
                var arr = ids.split(",");
                for(var i=0; i<arr.length;i++){
                    if(id == arr[i]){
                        boo = false;
                        break;
                    }
                }
                if(boo){
                    $("#ids").val(ids+","+id);
                }
                $("#icon"+id).html("<spring:message code='task_detial.message.msg2' />");
            }

        }
        $(function(){
            //tab切换
            $(".detailtabs ul li").click(function(){
                $(".detailtabs ul li.hover").removeClass("hover");
                $(this).addClass("hover");
                var i=$(this).attr("sid");
                $("div.tabspack").hide();
                $("#tab"+i).show();
            });
            //解析附件
            var attachment = '${detail.attachment}';
            var imgsuffix = "bmp/jpg/jpeg/png/gif";
            var zipsuffix = " rar/zip/7z/gz/bz/ace/uha/uda/zpaqf";
            var arr = attachment.split(",");
            var imgstr="";
            var userInfo = '${sessionScope.curUser}';
            if(userInfo != ''){
                if(arr.length > 0){
                    for(var i=0; i<arr.length;i++){
                        if(arr[i] != ''){
                            //图片
                            var suffix = arr[i].substring(arr[i].lastIndexOf(".")+1).toLowerCase();
                            var title =  arr[i].substring(arr[i].lastIndexOf("/")+1);
                            if(title > 29) title.substring(0,29)+"...";
                            if(imgsuffix.indexOf(suffix) != -1){
                                imgstr += '<li onclick=\'f_download("'+arr[i]+'")\'> '+
                                        '<img src="${path}/'+arr[i]+'" width="56" height="70" />'+
                                        ' <p>'+title+'</p>'+
                                        '</li>';
                            }else if(zipsuffix.indexOf(suffix) != -1){//压缩包
                                imgstr += '<li onclick=\'f_download("'+arr[i]+'")\'> '+
                                        '<img src="${path}/style/acg/images/filetype/zip.jpg" width="56" height="70" />'+
                                        ' <p>'+title+'</p>'+
                                        '</li>';
                            }else{
                                imgstr += '<li onclick=\'f_download("'+arr[i]+'")\'> '+
                                        '<img src="${path}/style/acg/images/filetype/'+suffix+'.jpg" width="56" height="70" />'+
                                        ' <p>'+title+'</p>'+
                                        '</li>';
                            }
                        }
                    }
                }
            }else{
                imgstr='<div class="detail_login">'+
                        '<spring:message code="task_detail.button.please"/><a href="${path}/login/index.html" class="btnlogin"><spring:message code="task_detail.button.login"/></a><spring:message code="task_detail.button.please2"/>'+
                        '<a href="${path}/register/toRegister.html" class="btnreg"><spring:message code="task_detail.button.register"/></a>'+
                        '</div>';
            }

            $("#attachment").html(imgstr);

            //存入最近浏览项目记录
            var itemId = '${detail.itemId}';
            if(itemId!=''){
                var hisstr = "${detail.itemId};${detail.pic};${detail.title};${detail.budget};${detail.progressName}";
                var history_task = $.cookie("history_task");
                if(history_task != null) {
                    var arr = history_task.split(",");
                    var boo =true

                    for(var i=0;i<arr.length;i++){
                        var itemId = '${detail.itemId}';
                        var arr2 = arr[i].split(";");
                        if(arr2[0] == itemId){
                            boo=false;
                            break;
                        }
                    }
                    //$.cookie("history_task",null,{ expires: 7, path: '/'});
                    if(boo){
                        //如果存入数据大于6
                        var arr3 = history_task.split(",");
                        if(arr3.length > 6){
                            arr3.splice(0,1);
                            history_task = arr3.join(",");
                        }
                        hisstr=history_task+","+hisstr;
                        $.cookie("history_task",hisstr,{ expires: 7, path: '/'});
                    }
                }else{
                    $.cookie("history_task",hisstr,{ expires: 7, path: '/'});
                }
            }

        });

    </script>
</head>
<body>
<jsp:include page="../public/header.jsp"></jsp:include>
<!--content-->
<div id="container">

    <div class="wrapper">
        <div class="detailshow_one">
            <div class="showphoto">
                <img src="${path}/${detail.pic}" width="450" height="450" />
            </div>
            <div class="summaryright">
                <h1>${detail.title}</h1>
                <div class="shuxing">
                    <span>
                       <em class="gj"></em>
                        <c:set var="languaget" value="zh_cn"></c:set>
                        <c:if test="${language != '' && language != null}">
                            <c:set var="languaget" value="${language}"></c:set>
                        </c:if>
                       <c:if test="${detail.country==languaget}"><spring:message code="task_detail.country"/></c:if>
                       <c:if test="${detail.country!=languaget}"><spring:message code="task_detail.country2"/></c:if>
                    </span>
                    <span>
                        <em class="top"></em>
                        <c:if test="${detail.isDeposit==101001}"><spring:message code="task_detail.trust_fund"/></c:if>
                        <c:if test="${detail.isDeposit==101002}"><spring:message code="task_detail.trust_fund2"/></c:if>
                    </span>
                </div>
                <div class="summarycon">
                    <p>
                        <spring:message code="task_detail.delegate"/>：${detail.nickname}
                        <span class="border">
                        <c:if test="${detail.userAuth==101001}">
                            <spring:message code="task_detail.nickname_auth"/>
                        </c:if>
                        <c:if test="${detail.userAuth!=101001}">
                            <spring:message code="task_detail.nickname_auth2"/>
                        </c:if>
                        </span>
                            &nbsp;&nbsp;&nbsp;&nbsp;<spring:message code="task_detail.task_id"/>：${detail.itemId}
                            &nbsp;&nbsp;&nbsp;&nbsp;<spring:message code="task_detail.task_class"/>：${detail.firstClass}
                    </p>
                    <p>
                        <spring:message code="task_detail.status"/>：<em>${detail.progressName}</em>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <spring:message code="task_detail.offer_total"/>
                        <em>
                            ${detail.bidTotal==''?0:detail.bidTotal}</em><spring:message code="task_detail.offer_total2"/>
                        <em>
                            <f:formatNumber value="${detail.bidAvg==null?0:detail.bidAvg}" pattern="#,#00.00#"/>
                        </em>
                    </p>
                    <p><spring:message code="task_detail.task_budget"/>：<em class="price">￥<f:formatNumber value="${detail.budget}" pattern="#,#00.00#"/></em></p>
                    <p>
                        <spring:message code="task_detail.start_time"/>：<script>
                        function NewDate(str) {
                            str = str.split(' ');
                            str1 = str[0].split('-');
                            str2 = str[1].split(':');
                            var date = new Date();
                            date.setUTCFullYear(str1[0], str1[1] - 1, str1[2]);
                            date.setUTCHours(str2[0], str2[1], str2[2], 0);
                            return date;
                        }
                        var startTime = NewDate('${detail.startTime}');document.write(startTime.Format("<spring:message code="task_detail.time_formatter"/>"));</script>

                        &nbsp;&nbsp;&nbsp;&nbsp; <spring:message code="task_detail.end_time"/>：
                            <script>
                            var endtime = NewDate('${detail.startTime}');
                            var bidTime = '${detail.bidTime}';
                            if(bidTime == -1){
                                document.write(" <spring:message code="task_detail.long_time"/>");
                            }else{
                                endtime =  new Date(endtime.getTime()+bidTime*24*60*60*1000);
                                var y =
                                        document.write(endtime.Format(" <spring:message code="task_detail.time_formatter"/>"));
                            }
                           </script>
                    </p>
                    <p><spring:message code="task_detail.style"/>：<em>${detail.style }</em>&nbsp;&nbsp;&nbsp;&nbsp;<spring:message code="task_detail.skill"/>：${detail.skill}</p>
                </div>
                <div class="summaryjs">
                    <h3><spring:message code="task_detail.simple_info"/>：</h3>
                    <p>
                        ${detail.demand}
                     </p>
                </div>
                <p>

                <c:if test="${detail.itemStatus == 107102}">

                      <c:if test="${isbid == 0 && detail.progress == 105105 && isMy != 1}">
                        <a href="${path}/bid/getTaskInfoByTaskId.html?taskId=${detail.itemId}" class="btntoubiao"><spring:message code="task_detail.bid_button"/></a>
                      </c:if>
                      <c:if test="${isbid > 0}"><a href="javascript:void(0);" class="btntoubiao"><spring:message code="task_detail.bid_button2"/></a></c:if>
                      <c:if test="${isbid < 0}"><a href="${path}/login/index.html" class="btntoubiao"><spring:message code="task_detail.bid_button3"/></a></c:if></p>
                    <c:if test="${isBidButton == 1}">
                        <a style="margin-left: 10px" href="javascript:void(0);" class="btntoubiao" onclick="winItem()"><spring:message code='task_detial.message.msg5' /></a>
                    </c:if>
                </c:if>


                <c:if test="${detail.itemStatus == 107104}">
                    <a href="javascript:void(0)" class="btntoubiao" style="background: #F0F0F0;">已关闭</a>
                </c:if>
                <c:if test="${detail.itemStatus == 107105}">
                    <a href="javascript:void(0)" class="btntoubiao" >已完成</a>
                </c:if>

            </div>
            <div class="clr"></div>
        </div>
        <div class="detailmain">
            <div class="ShowStep">
                <div class="RestTime"></div>
                <div class="StepMain">
                    <ul class="clearfix">
                        <li class="first ${detail.progress==105102?"on":""}">
                            <h3 <c:if test="${detail.progress>=105102}">class="hover"</c:if>>1</h3>
                            <p><spring:message code="task_detail.progress.first"/><br /><em></em></p>
                        </li>
                        <li ${detail.progress==105103?"class='on'":""}>
                            <h3 <c:if test="${detail.progress>=105103}">class="hover"</c:if>>2</h3>
                            <p><spring:message code="task_detail.progress.second"/><br /><em></em></p>
                        </li>
                        <li ${detail.progress==105105?"class='on'":""}>
                            <h3 <c:if test="${detail.progress>=105105}">class="hover"</c:if>>3</h3>
                            <p><spring:message code="task_detail.progress.third"/><br /><em></em></p>
                        </li>
                        <li ${detail.progress==105106?"class='on'":""}>
                            <h3 <c:if test="${detail.progress>=105106}">class="hover"</c:if>>4</h3>
                            <p><spring:message code="task_detail.progress.fourth"/><br /><em></em></p>
                        </li>
                        <li ${detail.progress==105108?"class='on'":""}>
                            <h3 <c:if test="${detail.progress>=105108}">class="hover"</c:if>>5</h3>
                            <p><spring:message code="task_detail.progress.fifth"/><br /><em></em></p>
                        </li>
                        <li ${detail.progress==105109?"class='on'":""}>
                            <h3 <c:if test="${detail.progress>=105109}">class="hover"</c:if>>6</h3>
                            <p><spring:message code="task_detail.progress.sixth"/><br /><em></em></p>
                        </li>
                        <li class="last ${detail.progress==105110?"on":""}">
                            <h3 <c:if test="${detail.progress>=105110}">class="hover"</c:if>>7</h3>
                            <p><spring:message code="task_detail.progress.seventh"/><br /><em></em></p>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="detailContent">
                <div class="detailtabs">
                    <ul>
                        <li class="hover" sid="1"><a href="javascript:void(0);" ><spring:message code="task_detail.tab1.title"/></a></li>
                        <li sid="2"><a href="javascript:void(0);"><spring:message code="task_detail.tab2.title"/></a></li>
                        <li sid="3"><a href="javascript:void(0);"><spring:message code="task_detail.tab3.title"/></a></li>
                    </ul>
                </div>
                <!--项目描述-->
                <div class="tabspack" id="tab1">
                    <div class="projectscon">
                        <p>${detail.description}</p>
                    </div>
                </div>
                <!--项目描述-->
                <!--项目附件-->
                <div class="tabspack" style="display: none" id="tab2">
                    <div class="project_files">
                        <ul class="clearfix" id="attachment">

                        </ul>
                    </div>
                </div>
                <!--项目附件-->
                <!--委托方资料-->
                <div class="tabspack" style="display: none"  id="tab3">
                    <div class="project_Entrust">
                        <div class="project_entrust_brif clearfix">
                            <div class="brifimg"><img src="${path}/${detail.headPortrait}" width="120" height="120" /></div>
                            <div class="brifmain">
                                <h2>${detail.nickname}</h2>
                                <div class="shuxing">
                                    <span>
                                    <c:if test="${detail.userAuth==101001}">
                                        <spring:message code="task_detail.nickname_auth"/>
                                    </c:if>
                                    <c:if test="${detail.userAuth!=101001}">
                                        <spring:message code="task_detail.nickname_auth2"/>
                                    </c:if>
                                    </span>
                                </div>
                                <p class="brif_jl">
                                    <spring:message code="task_detail.delegate.info.span1" arguments="${detail.orderTotal}" argumentSeparator=","/>
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <spring:message code="task_detail.delegate.info.span2" arguments="${detail.orderTotal}" argumentSeparator=","/>：￥${detail.orderTotalPrice==null?0:detail.orderTotalPrice}</p>
                                <p><a href="${path}/usercenter/toUserMessagesHome.html?sender=${detail.userId}" class="deltail_lxwm"><em class="icon"><spring:message code='task_detial.bid.contact' /></em></a></p>
                            </div>
                        </div>
                        <div class="project_entrust_con">
                            ${detail.intro}
                        </div>
                    </div>
                </div>
                <!--委托方资料-->
            </div>
        </div>
        <div class="detail_tit"><spring:message code="task_detail.artist.title"></spring:message></div>
        <div class="detail_artists">

            <c:if test='${sessionScope.curUser == null}'>
                <div class="detail_login">
                    <spring:message code="task_detail.button.please"/><a href="${path}/login/index.html" class="btnlogin"><spring:message code="task_detail.button.login"/></a><spring:message code="task_detail.button.please2"/>
                    <a href="${path}/register/toRegister.html" class="btnreg"><spring:message code="task_detail.button.register"/></a>
                </div>
            </c:if>
            <c:if test='${sessionScope.curUser != null}'>
                <div class="artistslist" id="artistslist">

                </div>
                <div id="kkpager" style="text-align: center"></div>
                <script type="text/javascript">
                    initBeanInfo(1,10);
                </script>
            </c:if>
        </div>
    </div>
</div>
<c:if test="${isBidButton == 1}">
<input type="hidden" id="ids" name="ids">
</c:if>
<!--content-->
<jsp:include page="../public/footer.jsp"></jsp:include>
</body>
</html>
